home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / Networking / SANA-II / slip_src / slip_device.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-06  |  5.9 KB  |  235 lines

  1. /*
  2. ** $Source: HOG:Other/networking/sana2/src/slip/RCS/slip_device.h,v $
  3. ** $State: Exp $
  4. ** $Revision: 38.1 $
  5. ** $Date: 94/02/17 14:17:15 $
  6. ** $Author: kcd $
  7. **
  8. ** SANA-II Example device driver C include file
  9. **
  10. ** (C) Copyright 1992-1998 Amiga, Inc.
  11. */
  12.  
  13. #include <exec/types.h>
  14. #include <exec/devices.h>
  15. #include <exec/ports.h>
  16. #include <exec/semaphores.h>
  17. #include <exec/memory.h>
  18. #include <dos.h>
  19. #include <devices/sana2.h>
  20. #include <devices/serial.h>
  21. #include <utility/hooks.h>
  22.  
  23. #ifdef    OWNDEVUNIT_SUPPORT
  24. /*#include <libraries/owndevunit.h>*/
  25. #include "odu/include/owndevunit.h"
  26. #endif
  27.  
  28. /* Berkely Stuff */
  29.  
  30. #include "param.h"
  31. #include "mbuf.h"
  32. #include "in.h"
  33. #include "in_systm.h"
  34. #include "ip.h"
  35. #include "tcp.h"
  36. #include "string.h"
  37. #include "slcompress.h"
  38.  
  39. /*
  40. ** Stacksize and Priority of the Unit Process
  41. */
  42. #define SLIP_STACKSIZE 4000
  43. #define SLIP_PRI 5
  44.  
  45. /*
  46. ** Maximum Transmission Unit
  47. */
  48. #define DEFAULT_SLIP_MTU 1006
  49.  
  50. /*
  51. ** Max # of Units allowed
  52. */
  53. #define SD_MAXUNITS 8
  54.  
  55. /*
  56. ** Message passed to the Unit Process at
  57. ** startup time.
  58. */
  59. struct StartupMessage
  60. {
  61.     struct Message    Msg;
  62.     struct Unit    *Unit;
  63.     struct Device    *Device;
  64. };
  65.  
  66. /*
  67. ** Device Data Structure
  68. */
  69. struct SLIPDevice
  70. {
  71.     struct Library     sd_Device;
  72.     UBYTE         sd_Flags;
  73.     UBYTE         sd_Pad1;
  74.     struct Library    *sd_SysBase;
  75.     struct Library    *sd_DOSBase;
  76.     ULONG         sd_DosTag[10];
  77.     BPTR         sd_SegList;
  78.     struct Unit        *sd_Units[SD_MAXUNITS];
  79.     struct SignalSemaphore sd_Lock;
  80.     struct StartupMessage sd_Startup;
  81.     struct Hook         sd_DummyPFHook;
  82. };
  83.  
  84. /*
  85. ** Typedef's for the SANA-II callback functions.
  86. */
  87. typedef BOOL (*SANA2_CFB)(APTR to, APTR from, LONG length);
  88. typedef BOOL (*SANA2_CTB)(APTR to, APTR from, LONG length);
  89.  
  90. struct BufferManagement
  91. {
  92.     struct MinNode    bm_Node;
  93.     SANA2_CFB        bm_CopyFromBuffer;
  94.     SANA2_CTB        bm_CopyToBuffer;
  95.     struct Hook           *bm_PacketFilterHook;    /* New SANA-II V2 Callback Hook */
  96.     struct MinList    bm_RxQueue;        /* Pending CMD_READS */
  97. };
  98.  
  99. struct SuperS2PTStats
  100. {
  101.     struct MinNode        ss_Node;
  102.     ULONG            ss_PType;
  103.     struct Sana2PacketTypeStats    ss_Stats;
  104. };
  105.  
  106. struct DQInfo
  107. {
  108.     UWORD    Type;
  109.     UWORD    Size;
  110.     ULONG    Data;
  111. };
  112.  
  113. #define DQ_CWORD    1
  114. #define DQ_CLONG    2
  115. #define DQ_MTU        3
  116. #define DQ_BPS        4
  117.  
  118. /*
  119. ** Unit Data Structure
  120. */
  121. struct SLIPUnit
  122. {
  123.     struct Unit             su_Unit;        /* Standard Unit Structure */
  124.     UBYTE             su_UnitNum;        /* Unit number */
  125.     UBYTE             su_Reserved0;        /* Padding */
  126.     struct Device        *su_Device;        /* Pointer to our device node */
  127.     ULONG             su_StAddr;        /* Our current "hardware" address */
  128.     ULONG             su_DefaultAddr;    /* Our default "hardware" address */
  129.     ULONG             su_BaudRate;        /* Serial baud rate */
  130.     ULONG             su_MTU;        /* Maximum Transmission Unit */
  131.     LONG             su_RBufLen;        /* Serial receive buffer size */
  132.     ULONG             su_SerUnitNum;        /* Serial driver unit number */
  133.     BOOL             su_Continue;
  134.     BOOL             su_Escape;        /* SLIP Decode state */
  135.     ULONG             su_State;        /* Various state information */
  136.     struct IOExtSer         *su_SerRx;        /* Serial IORequest for CMD_READ's */
  137.     struct IOExtSer         *su_SerTx;        /* Serial IORequest for CMD_WRITE's */
  138.     struct MsgPort         *su_RxPort;        /* Serial CMD_READ IORequest reply port */
  139.     struct MsgPort         *su_TxPort;        /* Serial CMD_WRITE IORequest reply port */
  140.     UBYTE            *su_RxBuff;        /* Buffer for holding decoded packets */
  141.     UBYTE            *su_RxBuffPtr;        /* Current place in decode buffer */
  142.     UBYTE            *su_TxBuff;        /* Temporary buffer for hold unencoded outgoing packets */
  143.     UBYTE            *su_RxSLIP;        /* Two buffers that hold packets encoded */
  144.     UBYTE            *su_TxSLIP;        /* in SLIP format. */
  145.     struct Process        *su_Proc;         /* NB: This points to the Task, not the MsgPort */
  146.     struct SignalSemaphore     su_ListLock;        /* A Semaphore for access to all of our queues. */
  147.     struct MsgPort        *su_Tx;            /* Pending CMD_WRITE's */
  148.     struct MsgPort        *su_TxFast;        /* Low-Delay CMD_WRITE's */
  149.     struct MinList          su_Events;        /* Pending S2_ONEVENT's */
  150.     struct SuperS2PTStats    *su_IPTrack;        /* For tracking IP packets */
  151.     struct MinList          su_Track;        /* List of packet types being tracked */
  152.     struct MinList         su_BuffMgmt;        /* List of Callback routines */
  153.     struct Sana2DeviceStats     su_Stats;        /* Global device statistics */
  154.     UBYTE              su_SerDevName[32];    /* Name of the serial driver to use */
  155. #ifdef OWNDEVUNIT_SUPPORT
  156.     struct Library        *su_ODUBase;        /* OwnDevUnit library base */
  157.     UBYTE             su_OwnerName[32];    /* name reported to ODU as owner of serial device */
  158. #endif
  159.     struct mbuf             su_MBuff;
  160.     struct slcompress         su_SLCompress;
  161. };
  162.  
  163. /*
  164. ** State bits for sdu_State
  165. */
  166.  
  167. #define SLIPUB_CONFIG        0
  168. #define SLIPUB_ONLINE        1
  169. #define SLIPUB_SETCONFIG    2
  170. #define SLIPUB_CD        3
  171. #define SLIPUB_EXCLUSIVE    4
  172. #define SLIPUB_7WIRE        5
  173. #define SLIPUB_MAYCOMPRESS    6
  174. #define SLIPUB_AUTOCOMP        7
  175.  
  176. #define SLIPUF_CONFIG        (1<<SLIPUB_CONFIG)
  177. #define SLIPUF_ONLINE        (1<<SLIPUB_ONLINE)
  178. #define SLIPUF_SETCONFIG    (1<<SLIPUB_SETCONFIG)
  179. #define SLIPUF_CD        (1<<SLIPUB_CD)
  180. #define SLIPUF_EXCLUSIVE    (1<<SLIPUB_EXCLUSIVE)
  181. #define SLIPUF_7WIRE        (1<<SLIPUB_7WIRE)
  182. #define SLIPUF_MAYCOMPRESS    (1<<SLIPUB_MAYCOMPRESS)
  183. #define SLIPUF_AUTOCOMP        (1<<SLIPUB_AUTOCOMP)
  184.  
  185. /*
  186. ** Type of Service Flags
  187. */
  188.  
  189. #define TOSF_LOWDELAY    0x10
  190. #define TOSF_HITHRUPUT    0x04
  191. #define TOSF_HIRELIABLE    0x02
  192.  
  193. /*
  194. ** Device Name
  195. */
  196.  
  197. #define SLIPDEVNAME "slip.device"
  198.  
  199. /*
  200. ** Packet Encoding Bytes
  201. */
  202.  
  203. #define SLIP_END     192
  204. #define SLIP_ESC     219
  205. #define SLIP_ESC_END 220
  206. #define SLIP_ESC_ESC 221
  207.  
  208. /*
  209. ** Useful define
  210. */
  211. #ifndef min
  212. #define min(a,b) ((a)<=(b)?(a):(b))
  213. #endif
  214.  
  215. /*
  216. ** Compiler Magic
  217. **
  218. */
  219.  
  220. #define SysBase        (slipDevice->sd_SysBase)
  221. #define DOSBase        (slipDevice->sd_DOSBase)
  222. #define OwnDevUnitBase    (slipUnit->su_ODUBase)
  223.  
  224. #if 1
  225. #define ASM           __asm
  226. #define REG(x)        register __ ## x
  227. #else
  228. #define ASM
  229. #define REG(x)
  230. #endif
  231.  
  232. typedef ULONG (* ASM HOOK_FUNC)(REG(a0) struct Hook *hook, REG(a2) APTR object, REG(a1) APTR message);
  233.  
  234. #define STDSLIPARGS REG(a2) struct IOSana2Req *ios2, REG(a4) struct SLIPUnit *slipUnit, REG(a6) struct SLIPDevice *slipDevice
  235.